package com.gnerv.author.controller;

import com.gnerv.author.service.IArticleStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Gnerv LiGen
 * @description
 * @data 2019/7/16
 */
@Controller
public class BlogController {

    @Autowired
    IArticleStatisticsService articleStatisticsService;

    @RequestMapping(value = "")
    public String index(){
        return "blog/index";
    }

    @RequestMapping(value = "article/{bId}")
    public String article(@PathVariable(value = "bId") String bId, ModelMap modelMap){
        modelMap.addAttribute("aId", bId);
        articleStatisticsService.updateBlogArticleStatisticsByClick(bId,1);
        return "blog/article";
    }

    @RequestMapping(value = "catalog/{bId}")
    public String catalog(@PathVariable(value = "bId") String bId, ModelMap modelMap){
        modelMap.addAttribute("cId", bId);
        return "blog/catalog";
    }

}
